#ifndef __APP_BUFF_H__
#define __APP_BUFF_H__
#include "pthread.h"
//小/子缓冲区
typedef struct
{
   unsigned char *ptr;//缓冲区指针
    int total_size;//缓冲区大小
    int len;//已使用大小
}SubBuffer;

//大缓冲区
typedef struct
{
    SubBuffer *sub_buffers[2];//包括两个子缓冲区的数组
    int read_index;//读索引
    int write_index;//写索引
    pthread_mutex_t read_lock;//读锁
    pthread_mutex_t write_lock;//写锁
}Buffer;


//初始化缓冲区
Buffer *app_buffer_init(int total_size);
//释放缓冲区
void app_buffer_free(Buffer *buffer);
//向缓冲区写入数据
int app_buffer_write(Buffer *buffer, char *data, int len);
//从缓冲区读取数据
int app_buffer_read(Buffer *buffer, char *data_buf, int buf_len);
#endif /* __APP_BUFF_H__ */